<template>
	<view>
		<view class="tabs">
			<view style="flex: 1;">
				<u-tabs ref="tabs" :list="list1" :scrollable="false" @change="tabschange"></u-tabs>
			</view>
		</view>
		<swiper class="swiper" :style="swiperstyle" :current="current" circular @change="swiperchange">
			<swiper-item>
				<charginglist ref="cdlist0" :seardata="{}"></charginglist>
			</swiper-item>
			<swiper-item>
				<placeholderlist ref="cdlist1"></placeholderlist>
			</swiper-item>
			<!-- <swiper-item>
				<cdlist ref="cdlist2" :seardata="{b_end:0}"></cdlist>
			</swiper-item> -->
		</swiper>
		<ztabbar></ztabbar>
	</view>
</template>

<script>
	import charginglist from "./components/chargingList.vue"
	import placeholderlist from "./components/placeholderList.vue"
	export default {
		components: {
			charginglist,
			placeholderlist
		},
		data() {
			return {
				list1: [{
						name: this.$z.$t("充电订单"),
					},
					{
						name: this.$z.$t("占位订单"),
					},
					// {
					// 	name: this.$z.$t("进行中"),
					// },
				],
				current: "1",
				swiperstyle: {},
				query: {}
			};
		},
		onLoad(query) {
			this.query = query;
			if (this.query.current) {
				this.current = this.query.current
			}
		},
		mounted() {
			this.init();
		},
		methods: {
			async init() {
				await this.$store.dispatch("user/getuser");
				uni.getSystemInfo({
					success: (res) => {
						this.swiperstyle.height = `calc(${res.screenHeight}px - 100rpx - 110rpx)`
					}
				})
				this.$refs.tabs.clickHandler({}, this.current)
				// this.$refs.cdlist2.onRefresh()
			},
			swiperchange(current) {
				console.log('current', current);
				this.$refs.tabs.clickHandler({}, current.detail.current)
			},
			tabschange(current) {
				this.current = current.index
				let cdlist = this.$refs[`cdlist${current.index}`]
				// status
				if (cdlist.status == "loadmore" && cdlist.list.length == 0) {
					cdlist.onRefresh()
				}
			}
		},
	};
</script>

<style lang="scss">
	page {
		background: #f4f7f8;
	}

	.tabs {
		background-color: #fff;
		height: 100rpx;
		display: flex;
		align-items: center;
	}

	.swiper {
		// height:926px
		// height: calc(603px - 100rpx - 110rpx);
		height: calc(100vh - 100rpx - 110rpx);
	}
</style>